<?php
    $this->layout('base.phtml', [
        'title' => _('Pocket authorization'),
        'canonical' => url_full('pocket auth'),
        'has_errors' => $error || $errors,
    ]);
?>

<div class="section">
    <div class="section__title">
        <h1><?= _('Pocket authorization') ?></h1>
    </div>

    <?php if ($error): ?>
        <?= $this->include('alerts/_error.phtml', ['message' => $error]) ?>

        <form method="post" action="<?= url('authorize pocket') ?>">
            <input type="hidden" name="csrf" value="<?= csrf_token() ?>" />
            <button type="submit" class="button--primary">
                <?= _('Check authorization') ?>
            </button>
        </form>
    <?php else: ?>
        <p class="paragraph--featured">
            <?= _('Please wait while we’re verifying access to Pocket…') ?>
        </p>

        <div class="spinner"></div>

        <form
             method="post"
             action="<?= url('authorize pocket') ?>"
             data-controller="autosubmit"
             data-autosubmit-mode-value="timeout"
         >
            <input type="hidden" name="csrf" value="<?= csrf_token() ?>" />
        </form>
    <?php endif; ?>
</div>
